package au.edu.swin.videoshop.bean;

import java.math.BigDecimal;

import au.edu.swin.videoshop.service.MiscUtil;

public class Customer extends Person {
	private Long mCustomerId;
	private BigDecimal mCredit;
	
	public Customer() {
	}
	
	
	/**
	 * @param customerId the customerId to set
	 */
	public void setCustomerId(Long customerId) {
		mCustomerId = customerId;
	}

	/**
	 * @return the customerId
	 */
	public Long getCustomerId() {
		return mCustomerId;
	}

	/**
	 * @return the credit
	 */
	public BigDecimal getCredit() {
		return mCredit;
	}
	
	/**
	 * @param credit the credit to set
	 */
	public void setCredit(BigDecimal credit) {
		mCredit = MiscUtil.round(credit);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj instanceof Customer) {
			return this.mCustomerId.equals(((Customer)obj).mCustomerId);
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return mCustomerId.hashCode();
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return mCustomerId.toString();
	}
}
